import mongoose  from 'mongoose'
import BaseModel from "./base_model"

let Schema    = mongoose.Schema;
let ObjectId  = Schema.ObjectId;

var ReplySchema = new Schema({
  appId:      { type: String, requried: true },
  content:    { type: String, requried: true },
  topic_id:   { type: ObjectId},
  author_id:  { type: ObjectId },
  reply_id:   { type: ObjectId },
  create_at:  { type: Date, default: Date.now },
  update_at:  { type: Date, default: Date.now },
  ups:        [Schema.Types.ObjectId],
  deleted:    {type: Boolean, default: false}
});

ReplySchema.plugin(BaseModel);
ReplySchema.index({topic_id: 1});
ReplySchema.index({author_id: 1, create_at: -1});

mongoose.model('Reply', ReplySchema);
